namespace iHouse.Model.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class _0 : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Album",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 100),
                        Singer = c.String(maxLength: 50),
                        Location = c.String(maxLength: 100),
                        PublishDate = c.DateTime(),
                        CategoryID = c.Int(nullable: false),
                        Language = c.Int(),
                        ImagePath = c.String(maxLength: 100),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Category", t => t.CategoryID, cascadeDelete: true)
                .Index(t => t.CategoryID);

            CreateTable(
                "dbo.Category",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 50),
                        TypeID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID);

            CreateTable(
                "dbo.Book",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(nullable: false, maxLength: 250),
                        Author = c.String(maxLength: 200),
                        Location = c.String(maxLength: 100),
                        PublishDate = c.DateTime(),
                        Type = c.Int(),
                        CategoryID = c.Int(),
                        Language = c.Int(),
                        ImagePath = c.String(maxLength: 100),
                        ISBN10 = c.String(maxLength: 20),
                        ISBN13 = c.String(maxLength: 20),
                        PublisherID = c.Int(),
                        Score = c.Decimal(precision: 18, scale: 2),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Category", t => t.CategoryID)
                .ForeignKey("dbo.Publisher", t => t.PublisherID)
                .Index(t => t.CategoryID)
                .Index(t => t.PublisherID);

            CreateTable(
                "dbo.Publisher",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 50),
                    })
                .PrimaryKey(t => t.ID);

            CreateTable(
                "dbo.Note",
                c => new
                    {
                        ID = c.Int(nullable: false, identity: true),
                        Title = c.String(nullable: false, maxLength: 200),
                        Description = c.String(),
                        CreatedDate = c.DateTime(nullable: false),
                        Reference = c.String(),
                        CategoryID = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.ID)
                .ForeignKey("dbo.Category", t => t.CategoryID, cascadeDelete: true)
                .Index(t => t.CategoryID);

        }

        public override void Down()
        {
            DropForeignKey("dbo.Note", "CategoryID", "dbo.Category");
            DropForeignKey("dbo.Book", "PublisherID", "dbo.Publisher");
            DropForeignKey("dbo.Book", "CategoryID", "dbo.Category");
            DropForeignKey("dbo.Album", "CategoryID", "dbo.Category");
            DropIndex("dbo.Note", new[] { "CategoryID" });
            DropIndex("dbo.Book", new[] { "PublisherID" });
            DropIndex("dbo.Book", new[] { "CategoryID" });
            DropIndex("dbo.Album", new[] { "CategoryID" });
            DropTable("dbo.Note");
            DropTable("dbo.Publisher");
            DropTable("dbo.Book");
            DropTable("dbo.Category");
            DropTable("dbo.Album");
        }
    }
}
